import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrphanVO, OrphanForm, OrphanQuery } from '@/api/business/orphan/types';

/**
 * 查询孤儿详细信息列表
 * @param query
 * @returns {*}
 */

export const listOrphan = (query?: OrphanQuery): AxiosPromise<OrphanVO[]> => {
  return request({
    url: '/business/orphan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询孤儿详细信息详细
 * @param userId
 */
export const getOrphan = (userId: string | number): AxiosPromise<OrphanVO> => {
  return request({
    url: '/business/orphan/' + userId,
    method: 'get'
  });
};

/**
 * 新增孤儿详细信息
 * @param data
 */
export const addOrphan = (data: OrphanForm) => {
  return request({
    url: '/business/orphan',
    method: 'post',
    data: data
  });
};
/**
 * 新增孤儿详细信息
 * @param data
 */
export const add = (data: OrphanForm) => {
  return request({
    url: '/business/orphan/sum',
    method: 'post',
    data: data
  });
};

/**
 * 修改孤儿详细信息
 * @param data
 */
export const updateOrphan = (data: OrphanForm) => {
  return request({
    url: '/business/orphan',
    method: 'put',
    data: data
  });
};

/**
 * 删除孤儿详细信息
 * @param userId
 */
export const delOrphan = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/business/orphan/' + userId,
    method: 'delete'
  });
};
